<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<!-- <script type="text/javascript" src="js/WeixinApi.js"></script>-->

<script>

  wx.config({
    debug: false, 
    appId: '{$Think.config.AppID}',
    timestamp: <?php echo $signPackage["timestamp"];?>,
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
    signature: '<?php echo $signPackage["signature"];?>',
    jsApiList: [
     'onMenuShareTimeline',
     'onMenuShareAppMessage',
     'onMenuShareQQ',
     'onMenuShareWeibo'
    ]
  });
  
  var title = '{$data.title}';
  var desc = '{$data.desc}';
  desc = desc ? desc :title;
  var link = 'http://{$Think.config.main_domain}{:U('passage/read',array( 'id'=>$data['id'] ,'cd'=>$userInfo['id'] ))}';
  var imgUrl = '';
  var type = 'link';
  var dataUrl = '';
  wx.ready(function () {
    // 在这里调用 API
      wx.onMenuShareTimeline({
            title: title, // 分享标题
            link: link, // 分享链接
            imgUrl: imgUrl, // 分享图标
            success: function () { 
                // 用户确认分享后执行的回调函数
               /*  $.post("addShare.shtml",{"page":"http://www.topbrandgroup.com/index.shtml","remoteAddr":"124.204.183.1"},function(data){
                    //window.location.href='http://www.topbrandgroup.com:80/index.shtml?type=second';
                },"json"); */
            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareAppMessage({
            title: title, // 分享标题
            desc: desc, // 分享描述
            link: link, // 分享链接
            imgUrl: imgUrl, // 分享图标
            type: 'link', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () { 
                // 用户确认分享后执行的回调函数
                /* $.post("addShare.shtml",{"page":"http://www.topbrandgroup.com/index.shtml","remoteAddr":"124.204.183.1"},function(data){
                    //window.location.href='http://www.topbrandgroup.com:80/index.shtml?type=second';
                },"json"); */
                
            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareQQ({
            title: title, // 分享标题
            desc: desc, // 分享描述
            link: link, // 分享链接
            imgUrl: imgUrl, // 分享图标
            success: function () { 
                // 用户确认分享后执行的回调函数
                /* $.post("addShare.shtml",{"page":"http://www.topbrandgroup.com/index.shtml","remoteAddr":"124.204.183.1"},function(data){
                    //window.location.href='http://www.topbrandgroup.com:80/index.shtml?type=second';
                },"json"); */
            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareWeibo({
            title: title, // 分享标题
            desc: desc, // 分享描述
            link: link, // 分享链接
            imgUrl: imgUrl, // 分享图标
            success: function () { 
                // 用户确认分享后执行的回调函数
                /* $.post("addShare.shtml",{"page":"http://www.topbrandgroup.com/index.shtml","remoteAddr":"124.204.183.1"},function(data){
                    //window.location.href='http://www.topbrandgroup.com:80/index.shtml?type=second';
                },"json"); */
            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数
            }
        });
  });
    
</script>